<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        ul {
            font-size: 20px;
            width: 700px;
            height: 50px;
            background-color: aquamarine;
            list-style: none;
            margin: 100px auto;
            text-align: center;
        }

        li {
            width: 700px;
            height: 50px;
            line-height: 50px;
            background-color: pink;
            border: 1px solid black;
        }
        span {
            margin-right: 20px;
        }
    </style>
</head>

<body>
    <!-- 1. 先准备一个容器 -->
    <div id="app">
        <ul>
            <li>
                <h3>欢迎光临小王的水果店</h3>
            </li>
            <li>
                <h5>苹果10¥/斤,折扣 8折</h5>
            </li>
            <li>请输入你要购买的斤数
                <input type="text" v-model="num">
            </li>
            <li><button @click="fn">结账买单</button></li>
            <li>结账单:
                <span >总价:{{total}}元</span>
                <span >折后价:{{discount}}元</span>
                <span >省了:{{save}}元</span>
            </li>
        </ul>
    </div>
    <!-- 2. 引框架 -->
    <script src="./vue.js"></script>
    <script>
        // 3.初始化vue实例对象
        const vm = new Vue({
            el: "#app",
            data: {
                total: 0,
                discount: 0,
                save: 0,
                num:0
            },
            methods: {
                fn() {
                   this.total=this.num*10,
                   this.discount=this.total*0.8,
                   this.save=this.total-this.discount
                }
            }
        });
    </script>
</body>

</html>